package com.jdbc1;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.Scanner;

public class Test {
	public int test() {
		int sum = 0;
		Connection cnn = DateBase.getcConnection();
		Scanner sc = new Scanner(System.in);
		System.out.println("请输入填空题答案：");
		String tk = sc.next();
		System.out.println("请输入单选题答案：");
		String dax = sc.next();
		System.out.println("请输入多选题答案：");
		String dux = sc.next();
		System.out.println("请输入判断题答案：");
		String pd = sc.next();
		String sql = " SELECT f( '"+tk+"','"+dax+"','"+dux+"','"+pd +"')";
		PreparedStatement ps ;
		try {
			ps = cnn.prepareStatement(sql);
			ResultSet rs = ps.executeQuery();
			while (rs.next()) {
				System.out.println("最终得分为："+rs.getString(1));
			}
		} catch (SQLException e1) {
			// TODO Auto-generated catch block
			e1.printStackTrace();
		}
		System.out.println("正确答案是：");
		String sql1="SELECT * FROM answer";
		try {
			ps = cnn.prepareStatement(sql1);
			ResultSet rs = ps.executeQuery();
			while(rs.next()){
				System.out.println("填空:"+rs.getString(3)+"\r\n单选:"+rs.getString(4)+"\r\n多选:"+rs.getString(5)+"\r\n判断:"+rs.getString(6));
			}
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}

		return sum;
	}

}
